package com.jinsi.service.tang.iml;

import com.jinsi.constant.TangConstant;
import com.jinsi.mapper.tang.PersonalProductListMapper;
import com.jinsi.pojo.Commodity;
import com.jinsi.pojo.SyUser;
import com.jinsi.service.tang.PersonalProductListService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.servlet.http.HttpSession;
import java.util.List;

/**
 * 个人商品列表
 * @author 唐文博
 * @Date 2022-08-13
 */
@Service
@Transactional
public class PersonalProductListServiceImpl implements PersonalProductListService {
    @Autowired
    private PersonalProductListMapper personalProductListMapper;

    /**
     * 查看表，全查,
     * @param session
     * @return
     */
    @Override
    @Transactional(readOnly = true)
    public List<Commodity> getPersonalProductListSee(HttpSession session) {
        SyUser user = (SyUser) session.getAttribute("user");
        return personalProductListMapper.getPersonalProductListSee(TangConstant.COMMODITY_ISDEL, user.getUserId());
    }

    /**
     * 模糊查
     * @param commodityName
     * @param classifyTitle
     * @param commodityLabel
     * @param session
     * @return
     */
    @Override
    public List<Commodity> getPersonalProductListLike(String commodityName, String classifyTitle,
                                                      String commodityLabel,HttpSession session) {
        SyUser user = (SyUser) session.getAttribute("user");
        return personalProductListMapper.getPersonalProductListLike(commodityName,classifyTitle,commodityLabel,
                TangConstant.COMMODITY_ISDEL, user.getUserId());
    }
}
